var express = require('express');
var router = express.Router();
var theatersApi = require('../api/theaters')
/* GET home page. */
router.get('/', async function (req, res, next) {//获取放映厅列表
    let { curPage, eachPage } = req.query;
    let data = await theatersApi.get({ curPage, eachPage });
    res.send(data);
});
router.post('/add', async function (req, res, next) {//添加放映厅
    let obj = req.body;
    let data = await theatersApi.add(obj);
    res.send(data);
});
router.get('/getOne', async function (req, res, next) {//获取放映厅列表
    let { _id } = req.query;
    console.log(_id, '+++++');
    let data = await theatersApi.getOne({ _id });
    res.send(data);
});
router.put('/:_id', async function (req, res, next) {//获取放映厅列表
    let { _id } = req.params;
    let theaters = req.body;
    let data = await theatersApi.upDate({ _id }, theaters);
    res.send(data);
});
router.delete('/:_id', async function (req, res, next) {//获取放映厅列表
    let { _id } = req.params;
    let data = await theatersApi.delete({ _id });
    res.send(data);
});
router.get('/search/:_id', async function (req, res, next) {//获取放映厅列表
    let { _id } = req.params;
    let data = await theatersApi.search({ _id });
    res.send({ "code": 0, "msg": "", "count": data.length, "data": data });
});


module.exports = router;
